import { Application, Graphics } from "pixi.js";

export class PixiController {
  private pixiApp: Application;
  constructor() {
    console.log("PixiApp");
    const app = new Application();
    this.pixiApp = app;
  }

  async initPixiApp() {
    const app = this.pixiApp
    const path2DContainer = document.getElementById(
      "path2d-container"
    ) as HTMLElement;

    await app.init({ background: "#1099bb", resizeTo: path2DContainer });
    path2DContainer.appendChild(app.canvas);
  }

  test() {
    // Create a Graphics object and draw a pixel-perfect line
    let graphics = new Graphics()
      .moveTo(0, 0)
      .lineTo(100, 100)
      .stroke({ color: 0xff0000, pixelLine: true });

    // Add it to the stage
    this.pixiApp.stage.addChild(graphics);

    // Even if we scale the Graphics object, the line remains 1 pixel wide
    graphics.scale.set(2);
  }
}
